package foo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class Employee implements Serializable, Cloneable, Comparable<Employee> {

	private static final long serialVersionUID = 1928136805743863520L;

	String name;
	int age;
	String role;

	transient List<String> jobs = new ArrayList<String>();

	public String getName() {
		return name;
	}

	public void setName(final String name) {
		this.name = name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(final int age) {
		this.age = age;
	}

	public String getRole() {
		return role;
	}

	public void setRole(final String role) {
		this.role = role;
	}

	public List<String> getJobs() {
		return jobs;
	}

	public void setJobs(final List<String> jobs) {
		this.jobs = jobs;
	}

	@Override
	public String toString() {
		return "Employee [name=" + name + ", age=" + age + ", role=" + role + ", jobs=" + jobs + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + age;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((role == null) ? 0 : role.hashCode());
		return result;
	}

	@Override
	public boolean equals(final Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final Employee other = (Employee) obj;
		if (age != other.age)
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (role == null) {
			if (other.role != null)
				return false;
		} else if (!role.equals(other.role))
			return false;
		return true;
	}

	@Override
	public Employee clone() throws CloneNotSupportedException {
		return (Employee) super.clone();
	}

	public int compareTo(final Employee o) {
		return this.name.compareTo(o.name);
	}
}
